package com.hjn.study.simplefactory;

public class ProductFactor {
    static class Person1 {
        public Person1() {
            System.out.println("this is Person1");
        }
    }

    static class Person2 {
        public Person2() {
            System.out.println("this is Person2");
        }
    }

    static Person1 person1 = null;
    static Person2 person2 = null;

    public static void create(int i) {
        if (i == 1) {
            person1 = new Person1();
        }
        if (i == 2) {
            person2 = new Person2();
        }
    }
    //简单工厂可指定参数，不必知道是如何创建对象的
    public static void main(String[] args) {
        create(1);
        create(2);
    }
}
